package com.chuan.thinkingjava.think4;

public class ThreadTest2 {
	
	public static void main(String[] args) {
		Runnable1 r1 = new Runnable1();
		Runnable2 r2 = new Runnable2();
		
		Thread t1 = new Thread(r1);
		Thread t2 = new Thread(r2);
		
		t1.start();
		t2.run();
		
		//总结调用run方法只是显现方法调用， 而start方法才是真正实现多并发的原理  启动线程处于就绪状态 等待执行run方法
	}
}

	class Runnable1 implements Runnable {

		@Override
		public void run() {
			for (int i = 0; i < 100; i++) {
				System.out.println(Thread.currentThread().getName() + "   在1执行" + i);
			}
		}
	}
	
	class Runnable2 implements Runnable {

		@Override
		public void run() {
			for (int i = 0; i < 100; i++) {
				System.out.println(Thread.currentThread().getName() + "  在2执行" + i);
			}
		}
	}
	
	class Thread1 extends Thread {
		
		public void run () {
			for (int i = 0; i < 100; i++) {
				System.out.println(Thread.currentThread().getName() + i + "在执行了");
			}
		}
	}
